<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>工作人员信息查看</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <script src="/static/js/editor/wangEditor.min.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <style>
        .discell {
            text-align:right;
            width:300px;
        }
        .input {
            width:400px;
        }
    </style>
</head>
<body>

<form id="form1" method="post" style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
    <!-- 编辑框START-->
    <div id="editform" class="form mini-fit" style="margin: 10px 0 40px;">
        <input name="id" class="mini-hidden" style="width: 100%;" />
        <input name="create_user" class="mini-hidden" style="width: 100%;" />
        <input name="addgovid" class="mini-hidden" style="width: 100%;" />
        <input name="fabulevel" class="mini-hidden" style="width: 100%;" />
        <input name="effective" class="mini-hidden" style="width: 100%;" />
        <input name="userlevel" class="mini-hidden" style="width: 100%;" value="${userlevel!''}" />
        <input name="adddate" class="mini-hidden" style="width: 100%;" value="${adddate!''}" />
        <input name="updateId" class="mini-hidden" style="width: 100%;" value="${updateId!''}" />
        <input name="update_user" class="mini-hidden" style="width: 100%;" value="${update_user!''}" />
        <table class="form-table" align="center">
            <tr>
                <td align="right"><font color="#dc143c">*</font>标题:</td>
                <td>
                    <input name="title" id="title" class="mini-textbox" style="width: 265px" required="true" type="text" />
                </td>
                <td>是否标红:</td>
                <td>
                    <input name="c_color" id="c_color" class="mini-checkboxlist"
                           data="[{ id: 1, name: '是' }]"
                           textField="name" valueField="id" value="1" />
                </td>
            </tr>
            <tr>
                <td align="right"><font color="#dc143c">*</font>发布范围:</td>
                <#if userlevel=='07'>
                    <td colspan="3" class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged="changeXjyh()"
                               data="[{ id: 07, name: '地市司法局' },{ id: 08, name: '区县司法局' },
                                       { id: 03, name: '基层司法所' }]" />
                    </td>
                <#elseif userlevel=='08'>
                    <td colspan="3" class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged="changeXjyh()"
                               data="[{ id: 08, name: '区县司法局' },{ id: 03, name: '基层司法所' }]" />
                    </td>
                <#elseif userlevel=='09'>
                    <td colspan="3" class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged="changeXjyh()"
                               data="[{ id: 09, name: '监狱局' },{ id: 01, name: '监所' }]" />
                    </td>
                <#elseif userlevel=='06'>
                    <td colspan="3" class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged="changeXjyh()"
                               data="[{ id: 06, name: '省司法厅' },{ id: 07, name: '地市司法局' },
                               { id: 08, name: '区县司法局' },{ id: 03, name: '基层司法所' },
                               { id: 09, name: '监狱局' },{ id: 01, name: '监所' }]" />
                    </td>
                <#else>
                    <td colspan="3" class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged="changeXjyh()"
                               data="[{ id: 06, name: '省司法厅' },{ id: 07, name: '地市司法局' },
                               { id: 08, name: '区县司法局' },{ id: 03, name: '基层司法所' },
                               { id: 01, name: '监所' }]" />
                    </td>
                </#if>
            </tr>
            <tr>
            <tr>
                <td align="right"><font color="#dc143c">*</font>有效期:</td>
                <td>
                    <input name="enddate" id="enddate" class="mini-combobox" style="width: 265px" required="true"
                           textField="codeName" valueField="codeId" emptyText="请选择..."
                           url="/azbj/tzgggl/noticeInfo/getnoticeType?codeType=3_8"
                    />
                </td>
            </tr>
            <tr>
                <td align="right" style="vertical-align:text-top;"><font color="#dc143c">*</font>内容:</td>
                <td colspan="3">
                    <div id="content" name="content" style="width: 600px;">
                    </div>
                </td>
            </tr>
            <tr>
                <td align="right">附件上传:</td>
                <td>
                    <input id="upload" type="button" onclick="onFileUpload()" value="上传" style="width: 112px" colspan="2" />
                    <span id="msg1"></span>
                    <div><b>支持扩展名:</b>.rar .zip .doc .docx .xls .xlsx .pdf .jpg</div>
                </td>
                </td>
            </tr>
        </table>
    </div>
    <!--编辑框END-->
    <div style="width:100%; position: absolute;bottom: 0;line-height: 40px;border-top: 1px solid #dfdfdf;text-align: center;">
        <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()">保存</a>
        <a class="mini-button" iconCls="fa-undo" plain="true" onclick="onCancel()">取消</a>
    </div>
</form>

<script type="text/javascript">
    mini.parse();
    var E = window.wangEditor;
    var editor = new E('#content');
    editor.customConfig.menus = [
        'head',  // 标题
        'bold',  // 粗体
        'fontSize',  // 字号
        'fontName',  // 字体
        'italic',  // 斜体
        'foreColor',  // 文字颜色
        'backColor',  // 背景颜色
        'link',  // 插入链接
        'justify',  // 对齐方式
        'image',  // 插入图片
        'undo',  // 撤销
        'redo'  // 重复
    ];
    editor.customConfig.uploadImgShowBase64 = true;
    // 隐藏“网络图片”tab
    editor.customConfig.showLinkImg = false;
    editor.customConfig.zIndex = 100;
    editor.create();
    var form = new mini.Form("form1");
    var adddate = mini.getByName("adddate").getValue();
    var update_user = mini.getByName("update_user").getValue();
    var updateId = mini.getByName("updateId").getValue();
    //标准方法接口定义
    function SetData(data) {
        var o = mini.decode(data);
        form.setData(o);
        form.setChanged(false);
        editor.txt.html(data.content);
        mini.getByName("c_color").setValue(data.cColor);
        var create_user = data.createUser;
        mini.getByName("create_user").setValue(create_user);
        //页面一加载 显示上传多少条
        mini.getByName("id").setValue(data.id);
        $.ajax({
            url:"/upload/downloadAppendixFile/getCountall?1=1&priNum="+data.id+"&taskId=21",
            type:"get",
            success: function (success){
                $('#msg1').text("上传成功" + success.data + "条!")
            }
        })
    }
    function saveData() {
        if (editor.txt.text().length == 0) {
            mini.alert("内容不能为空");
            return;
        }
        //验证非空字段
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        var data = form.getData();
        var content = editor.txt.html();
        data.content = content;
        data.adddate = adddate;
        data.updateId = updateId;
        data.update_user=update_user;
        if (mini.getByName("enddate").getValue().length > 1 && mini.getByName("enddate").getValue() != '99') {
            if (mini.getByName("enddate").getValue() == '一天') {
                data.enddate = '1';
            } else if (mini.getByName("enddate").getValue() == '二天') {
                data.enddate = '2';
            } else if (mini.getByName("enddate").getValue() == '三天') {
                data.enddate = '3';
            } else if (mini.getByName("enddate").getValue() == '七天') {
                data.enddate = '7';
            } else {
                data.enddate = '99';
            }
        }
        var json = mini.encode(data);
        commonSaveData("/azbj/tzgggl/noticeInfoManage/save", {data: json}, callback);
        // 保存成功的回调函数
        function callback() {
            mini.alert("保存成功", "成功", window.CloseOwnerWindow);
        }
    }

    // 上传附件 taskId=21 代表通知公告
    function onFileUpload() {
        var id = mini.getByName("id").getValue();
        commonEdit("/upload/user/uploadAppendixfile/view?1=1&id=" + id + "&priNum=" + id + "&taskId=21", null, null, 600, 400, true, true, true,callback);
        function callback(){
            $.ajax({
                url: "/upload/downloadAppendixFile/getCountall?1=1&priNum="+id+"&taskId=21",
                type: "get",
                success: function(success){
                    $("#msg1").text("上传成功" + success.data + "条!");
                }
            })
        }
    }
</script>
</body>
</html>